﻿using LyData.Data;
using System;
using System.Data;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_ad : System.Web.UI.Page
{
    string Flag = HttpContext.Current.Request.QueryString["YX_Flag"];
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Msg.Visible = false;
        this.Msg.CssClass = "msg";
        if (!base.IsPostBack)
        {
            this.BindToData();
        }
    }

    private void BindToData()
    {
        string Fs = Request.QueryString["YX_FS"];
        string ID = Request.QueryString["YX_MID"];
        int TypeID = 1;
        MenuName.Text = "广告管理"; 
        if (Fs == "Edit")
        {
            WebPublic.WebPublic.ReplaceBadChar(ID);
            string strwhere = string.Format("ID={0}",ID);
            IDb db = new DbFactory().DriverDb();
            db.Open();
            DataRow row = db.TopRow("*", "[Ad]", strwhere, "ID desc");
            db.Close();
            if (row!=null)
            {
                TypeID = Convert.ToInt16(row["AdType"]);
                switch (TypeID)
                {
                    case 1: this.RadioButton1.Checked = true;
                        this.TextBox1.Text = row["AdName"].ToString();
                        this.imgUrl.Value = row["AdAddr"].ToString();
                        this.TextBox4.Text = row["AdUrl"].ToString();
                        this.TextBox6.Text = row["AdWidth"].ToString();
                        this.TextBox8.Text = row["AdHeight"].ToString();
                        this.TextBox3.Text = row["AdExp"].ToString();
                        this.TextBox7.Text = row["AdBz"].ToString();

                        this.Panel1.Visible = false;
                        this.Panel2.Visible = false;
                        this.Panel3.Visible = true;
                        this.Panel4.Visible = false;
                        this.Panel5.Visible = false;
                        this.Panel6.Visible = false;
                        this.Panel7.Visible = false;
                        break;
                    case 2: this.RadioButton2.Checked = true;


                        this.TextBox1.Text = row["AdName"].ToString();
                        this.imgUrl.Value = row["AdAddr"].ToString();
                        this.TextBox4.Text = row["AdUrl"].ToString();
                        this.TextBox6.Text = row["AdWidth"].ToString();
                        this.TextBox8.Text = row["AdHeight"].ToString();
                        this.TextBox3.Text = row["AdExp"].ToString();
                        this.TextBox7.Text = row["AdBz"].ToString();

                        this.Panel1.Visible = false;
                        this.Panel2.Visible = false;
                        this.Panel3.Visible = true;
                        this.Panel4.Visible = false;
                        this.Panel5.Visible = false;
                        this.Panel6.Visible = false;
                        this.Panel7.Visible = false;
                        break;
                    case 3: this.RadioButton16.Checked = true;


                        this.TextBox19.Text = row["AdName"].ToString();
                        this.TextBox23.Text = row["AdExp"].ToString();
                        this.imgUrlx2.Text = row["AdAddr"].ToString();
                        this.lbimgUrl2.Text = row["AdAddr"].ToString();//幻灯片
                        this.TextBox21.Text = row["AdWidth"].ToString();
                        this.TextBox22.Text = row["AdHeight"].ToString();
                        this.TextBox20.Text = row["AdUrl"].ToString();
                        this.TextBox24.Text = row["AdBz"].ToString();


                        this.Panel1.Visible = false;
                        this.Panel2.Visible = false;
                        this.Panel3.Visible = false;
                        this.Panel4.Visible = false;
                        this.Panel6.Visible = false;
                        this.Panel5.Visible = true;
                        this.Panel7.Visible = false;
                        break;
                    case 4: this.RadioButton3.Checked = true;
                        this.TextBox32.Text = row["AdName"].ToString();
                        this.lbTextBox33.Text = row["TextBox33"].ToString();//对联
                        this.TextBox34.Text = row["AdUrl"].ToString();
                        this.TextBox33.Text = row["AdAddr"].ToString();
                        this.TextBox35.Text = row["AdWidth"].ToString();
                        this.TextBox36.Text = row["AdHeight"].ToString();
                        this.TextBox37.Text = row["AdExp"].ToString();
                        this.TextBox38.Text = row["AdBz"].ToString();
                        this.Panel1.Visible = false;
                        this.Panel2.Visible = false;
                        this.Panel3.Visible = false;
                        this.Panel4.Visible = false;
                        this.Panel6.Visible = false;
                        this.Panel5.Visible = false;
                        this.Panel7.Visible = true;
                        break;
                }
            }
        }
        else if (Fs == "Add")
        {

            this.Panel1.Visible = false;
            this.Panel2.Visible = true;
            this.Panel3.Visible = false;
            this.Panel4.Visible = false;
            this.Panel5.Visible = false;
            this.Panel6.Visible = false;
            this.Panel7.Visible = false;
            this.RadioButton4.Checked = true;
            this.TextBox9.Text = "0";
            this.TextBox10.Text = "0";
        }
        else if (Fs == "Slide")
        {

            this.Panel1.Visible = false;
            this.Panel2.Visible = false;
            this.Panel3.Visible = false;
            this.Panel4.Visible = true;
            this.Panel5.Visible = false;
            this.Panel6.Visible = false;
            this.Panel7.Visible = false;
            this.RadioButton12.Checked = true;
            this.TextBox15.Text = "0";
            this.TextBox16.Text = "0";
        }
        else if (Fs == "dob")
        {
            this.Panel1.Visible = false;
            this.Panel2.Visible = false;
            this.Panel3.Visible = false;
            this.Panel4.Visible = false;
            this.Panel5.Visible = false;
            this.Panel6.Visible = true;
            this.Panel7.Visible = false;
            this.RadioButton9.Checked = true;
            this.TextBox28.Text = "0";
            this.TextBox29.Text = "0";
        }
        else if (Fs == null)
        {
            this.Panel1.Visible = true;
            this.Panel2.Visible = false;
            this.Panel3.Visible = false;
            this.Panel4.Visible = false;
            this.Panel5.Visible = false;
            this.Panel6.Visible = false;
            this.Panel7.Visible = false;
            bind(Flag);

        }
    }

    private void bind(string flag)
    {

        int Fg = Convert.ToInt16(flag);
        string strwhere= "";
        switch (Fg)
        {
            case 0:
                strwhere = "1=1";
                break;
            case 1:
                strwhere = string.Format("AdType={0}", "1"); 
                break;
            case 2:
                strwhere = string.Format("AdType={0}", "2"); 
                break;
            case 3:
                strwhere = string.Format("AdType={0}", "3"); 
                break;
            case 4:
                strwhere = string.Format("AdType={0}", "4"); 
                break;
        }

        IDb db = new DbFactory().DriverDb();
        db.Open();
        DataSet ds = db.DataSet("*", "[Ad]", strwhere, "ID desc");
        db.Close();
        if (ds != null)
        {
            this.dg1.DataSource = datalistbind(ds);
            this.dg1.DataBind();
        }
        else
        {
            this.dg1.DataSource = null;
            this.dg1.DataBind();
        }
        
    }//绑定列表

    private PagedDataSource datalistbind(DataSet dst)
    {
        PagedDataSource objpage = new PagedDataSource();
        objpage.DataSource = dst.Tables[0].DefaultView;
        objpage.AllowPaging = true;
        objpage.PageSize = 20;
        int CurPage;
        //判断是否有分页的请求；

        ///
        if (Request["iPage"] != null)
        {
            CurPage = Convert.ToInt32(Request["iPage"]);
        }
        else
        {
            CurPage = 1;
        }
        //设置当前页；
        objpage.CurrentPageIndex = CurPage - 1;
        Label1.Text = "当前页：第" + CurPage.ToString() + "/" + objpage.PageCount + "页";
        Label2.Text = "共有" + objpage.DataSourceCount + "条记录　" + objpage.PageSize + "/页";
        //判断不是第一页的时候


        if (!objpage.IsFirstPage)
        {

            this.prev.NavigateUrl = Request.CurrentExecutionFilePath + "?iPage=" + (Convert.ToInt32(CurPage) - 1) + "&YX_Flag=" + Flag;
        }
        this.start.NavigateUrl = Request.CurrentExecutionFilePath + "?iPage=1" + "&YX_Flag=" + Flag;
        //判断不是最后一页的时候
        if (!objpage.IsLastPage)
        {
            this.next.NavigateUrl = Request.CurrentExecutionFilePath + "?ipage=" + (Convert.ToInt32(CurPage) + 1) + "&YX_Flag=" + Flag;
        }
        this.max.NavigateUrl = Request.CurrentExecutionFilePath + "?iPage=" + objpage.PageCount + "&YX_Flag=" + Flag;
        if (!IsPostBack)
        {
            for (int i = 1; i < objpage.PageCount + 1; i++)
            {
                this.iPage.Items.Add(new ListItem(i.ToString() + "页", i.ToString()));
            }
        }
        return objpage;
    }//分页

    public string RetAdName(int ID)
    {
        string Name = "";
        switch (ID)
        {
            case 1: Name = "图片广告"; break;
            case 2: Name = "Flash广告"; break;
            case 3: Name = "幻灯片广告"; break;
            case 4: Name = "对联广告"; break;
        }
        return Name;
    }  //转换文字

    protected void dg1_ItemDataBound(object sender, DataGridItemEventArgs e)//
    {
        if (e.Item.ItemIndex == -1)
        {
            return;
        }
        e.Item.Attributes.Add("bgcolor", "#EFFFDA");
        //  e.Item.Attributes.Add("style", "cursor:hand");
        e.Item.Attributes.Add("onMouseOver=this.style.backgroundColor", "#EDEBEF");
        e.Item.Attributes.Add("onMouseOut=this.style.backgroundColor", "#F6F6F6");
    }

    protected void Button2_Click(object sender, EventArgs e)//执行删除操作
    {
        string strwhere = string.Format("ID IN({0})", Request.Form["YX_CH"]);
        IDb db = new DbFactory().DriverDb();
        db.Open();
        int conut = db.Delete("[Ad]", strwhere);
        db.Close();
        if (conut > 0)
        {
            WebPublic.WebPublic.ShowAndRedirect(this, "执行成功！", "ad.aspx");
        }
        else
        {
            WebPublic.WebPublic.Show(this, "执行失败！");
        }
    }

    private string UpPicStr(string str, string reg)//过滤路径
    {
        bool Flag = false;
        string strings;

        Flag = System.Text.RegularExpressions.Regex.IsMatch(str, reg);
        if (Flag)
        {
            int Num = str.Length - 1;
            strings = str.Substring(0, Num);
        }
        else
        {
            strings = str;
        }
        return strings;
    }

    protected void sic(object sender, EventArgs e) // 分页
    {
        int flag = Convert.ToInt16(Flag);
        string strwhere = "";
        switch (flag)
        {
            case 0:
                strwhere = "1=1";
                break;
            case 1:
                strwhere = string.Format("AdType={0}", "1");
                break;
            case 2:
                strwhere = string.Format("AdType={0}", "2");
                break;
            case 3:
                strwhere = string.Format("AdType={0}", "3");
                break;
            case 4:
                strwhere = string.Format("AdType={0}", "4");
                break;
        }

        IDb db = new DbFactory().DriverDb();
        db.Open();
        DataSet ds = db.DataSet("*", "[Ad]", strwhere, "ID desc");
        db.Close();

        PagedDataSource objpage = new PagedDataSource();
        objpage.DataSource = ds.Tables[0].DefaultView;
        objpage.AllowPaging = true;
        //dg1.PageSize = 20;
        objpage.PageSize = 20;
        int CurPage;
        //判断是否有分页的请求；

        ///
        if (iPage.SelectedValue != null)
        {
            CurPage = Convert.ToInt32(iPage.SelectedValue);
        }
        else
        {
            CurPage = 1;
        }
        //设置当前页；
        objpage.CurrentPageIndex = CurPage - 1;
        Label1.Text = "当前页：第" + CurPage.ToString() + "/" + objpage.PageCount + "页";
        Label2.Text = "共有" + objpage.DataSourceCount + "条记录　" + objpage.PageSize + "/页";
        //判断不是第一页的时候


        if (!objpage.IsFirstPage)
        {

            this.prev.NavigateUrl = Request.CurrentExecutionFilePath + "?iPage=" + (Convert.ToInt32(CurPage) - 1) + "&YX_Flag=" + Flag; ;
        }
        this.start.NavigateUrl = Request.CurrentExecutionFilePath + "?iPage=1" + "&YX_Flag=" + Flag; ;
        //判断不是最后一页的时候
        if (!objpage.IsLastPage)
        {
            this.next.NavigateUrl = Request.CurrentExecutionFilePath + "?ipage=" + (Convert.ToInt32(CurPage) + 1) + "&YX_Flag=" + Flag; ;
        }
        this.max.NavigateUrl = Request.CurrentExecutionFilePath + "?iPage=" + objpage.PageCount + "&YX_Flag=" + Flag; ;
        if (!IsPostBack)
        {
            for (int i = 1; i < objpage.PageCount + 1; i++)
            {
                this.iPage.Items.Add(new ListItem(i.ToString() + "页", i.ToString()));
            }
        }
        this.dg1.DataSource = objpage; //ds.Tables["dstable"].DefaultView;
        this.dg1.DataBind();
    }

    #region      ------------------添加、修改-------------------

    protected void Button1_Click1(object sender, EventArgs e)//添加图片、FLASE
    {
        string TypeID = "1";
        if (this.RadioButton4.Checked)
        {
            TypeID = "1";
        }
        if (this.RadioButton5.Checked)
        {
            TypeID = "2";
        }
        string[,] includeColumns = new string[,]{
                    {"AdType",TypeID,"int","0"},
                    {"AdName",this.TextBox2.Text,"nvarchar","32"},
                    {"AdUrl",this.TextBox5.Text,"nvarchar","0"},
                    {"AdExp",this.TextBox12.Text,"nvarchar","0"},
                    {"AdWidth",this.TextBox9.Text,"nvarchar","32"},
                    {"AdHeight",this.TextBox10.Text,"nvarchar","32"},
                    {"AdAddr",this.T1.Value,"nvarchar","0"},
                    {"AdBz",this.TextBox12.Text,"NText","0"},
                    {"Addtime",DateTime.Now.ToString(),"DateTime","32"}
        };

        IDb db = new DbFactory().DriverDb();
        db.Open();
        int conut = db.Insert("[Ad]", includeColumns);
        db.Close();
        if (conut > 0)
        {
            WebPublic.WebPublic.ShowAndRedirect(this, "添加成功！", "ad.aspx");
        }
        else
        {
            WebPublic.WebPublic.Show(this, "添加失败！");
            return;
        }
    }

    protected void Button3_Click1(object sender, EventArgs e)//修改图片、FLASE
    {
        string ID=Request.QueryString["YX_MID"];
        WebPublic.WebPublic.ReplaceBadChar(ID);
        string TypeID = "1";
        if (this.RadioButton1.Checked)
        {
            TypeID = "1";
        }
        if (this.RadioButton2.Checked)
        {
            TypeID = "2";
        }
        string strwhere=string.Format("ID={0}",ID);
        string[,] includeColumns = new string[,]{
                    {"AdType",TypeID,"int","0"},
                    {"AdName",this.TextBox1.Text,"nvarchar","32"},
                    {"AdUrl",this.TextBox4.Text,"nvarchar","0"},
                    {"AdExp",this.TextBox3.Text,"nvarchar","0"},
                    {"AdWidth",this.TextBox6.Text,"nvarchar","32"},
                    {"AdHeight",this.TextBox8.Text,"nvarchar","32"},
                    {"AdAddr", this.imgUrl.Value,"nvarchar","0"},
                    {"AdBz",this.TextBox7.Text,"NText","0"},
                    {"Addtime",DateTime.Now.ToString(),"DateTime","32"}
        };

        IDb db = new DbFactory().DriverDb();
        db.Open();
        int conut = db.Update("[Ad]", includeColumns, strwhere);
        db.Close();
        if (conut > 0)
        {
            WebPublic.WebPublic.ShowAndRedirect(this, "修改成功！", "ad.aspx");
        }
        else
        {
            WebPublic.WebPublic.Show(this, "修改失败！");
            return;
        }
    }

    protected void Button6_Click(object sender, EventArgs e)//添加幻灯片
    {
        string TypeID = "3";
        string[,] includeColumns = new string[,]{
                    {"AdType",TypeID,"int","0"},
                    {"AdName",this.TextBox13.Text,"nvarchar","32"},
                    {"AdUrl",this.TextBox14.Text,"nvarchar","0"},
                    {"AdExp",this.TextBox17.Text,"nvarchar","0"},
                    {"AdWidth",this.TextBox15.Text,"nvarchar","32"},
                    {"AdHeight",this.TextBox16.Text,"nvarchar","32"},
                    {"AdAddr",UpPicStr(this.imgUrlx.Text, @"\w\|"),"nvarchar","32"},
                    {"AdBz",this.TextBox18.Text,"NText","0"},
                    {"Addtime",DateTime.Now.ToString(),"DateTime","32"}
        };
        IDb db = new DbFactory().DriverDb();
        db.Open();
        int conut = db.Insert("[Ad]", includeColumns);
        db.Close();
        if (conut > 0)
        {
            WebPublic.WebPublic.ShowAndRedirect(this, "添加成功！", "ad.aspx");
        }
        else
        {
            WebPublic.WebPublic.Show(this, "添加失败！");
            return;
        }
    }

    protected void Button8_Click(object sender, EventArgs e)//修改幻灯片
    {
        string ID = Request.QueryString["YX_MID"];
        WebPublic.WebPublic.ReplaceBadChar(ID);
        string TypeID = "3";

        string strwhere = string.Format("ID={0}", ID);
        string[,] includeColumns = new string[,]{
                    {"AdType",TypeID,"int","0"},
                    {"AdName",this.TextBox19.Text,"nvarchar","32"},
                    {"AdUrl",this.TextBox20.Text,"nvarchar","0"},
                    {"AdExp",this.TextBox23.Text,"nvarchar","0"},
                    {"AdWidth",this.TextBox21.Text,"nvarchar","32"},
                    {"AdHeight",this.TextBox22.Text,"nvarchar","32"},
                    {"AdAddr", UpPicStr(this.imgUrlx2.Text + "|", @"\w\|"),"nvarchar","0"},
                    {"AdBz",this.TextBox24.Text,"NText","0"},
                    {"Addtime",DateTime.Now.ToString(),"DateTime","32"}
        };

        IDb db = new DbFactory().DriverDb();
        db.Open();
        int conut = db.Update("[Ad]", includeColumns, strwhere);
        db.Close();
        if (conut > 0)
        {
            WebPublic.WebPublic.ShowAndRedirect(this, "修改成功！", "ad.aspx");
        }
        else
        {
            WebPublic.WebPublic.Show(this, "修改失败！");
            return;
        }
    }

    protected void Button10_Click(object sender, EventArgs e)//添加对联
    {
        string TypeID = "4";
        string[,] includeColumns = new string[,]{
                    {"AdType",TypeID,"int","0"},
                    {"AdName",this.TextBox25.Text,"nvarchar","32"},
                    {"AdUrl",this.TextBox27.Text,"nvarchar","0"},
                    {"AdExp",this.TextBox30.Text,"nvarchar","0"},
                    {"AdWidth",this.TextBox28.Text,"nvarchar","32"},
                    {"AdHeight",this.TextBox29.Text,"nvarchar","32"},
                    {"AdAddr",UpPicStr(this.TextBox26.Text, @"\w\|"),"nvarchar","0"},
                    {"AdBz",this.TextBox31.Text,"NText","0"},
                    {"Addtime",DateTime.Now.ToString(),"DateTime","32"}
        };
        IDb db = new DbFactory().DriverDb();
        db.Open();
        int conut = db.Insert("[Ad]", includeColumns);
        db.Close();
        if (conut > 0)
        {
            WebPublic.WebPublic.ShowAndRedirect(this, "添加成功！", "ad.aspx");
        }
        else
        {
            WebPublic.WebPublic.Show(this, "添加失败！");
            return;
        }
    }

    protected void Button12_Click(object sender, EventArgs e)//修改对联
    {
        string ID = Request.QueryString["YX_MID"];
        WebPublic.WebPublic.ReplaceBadChar(ID);
        string TypeID = "4";

        string strwhere = string.Format("ID={0}", ID);
        string[,] includeColumns = new string[,]{
                    {"AdType",TypeID,"int","0"},
                    {"AdName",this.TextBox32.Text,"nvarchar","32"},
                    {"AdUrl",this.TextBox34.Text,"nvarchar","0"},
                    {"AdExp",this.TextBox37.Text,"nvarchar","0"},
                    {"AdWidth",this.TextBox35.Text,"nvarchar","32"},
                    {"AdHeight",this.TextBox36.Text,"nvarchar","32"},
                    {"AdAddr", UpPicStr(this.TextBox33.Text + "|", @"\w\|"),"nvarchar","0"},
                    {"AdBz",this.TextBox38.Text,"NText","0"},
                    {"Addtime",DateTime.Now.ToString(),"DateTime","32"}
        };

        IDb db = new DbFactory().DriverDb();
        db.Open();
        int conut = db.Update("[Ad]", includeColumns, strwhere);
        db.Close();
        if (conut > 0)
        {
            WebPublic.WebPublic.ShowAndRedirect(this, "修改成功！", "ad.aspx");
        }
        else
        {
            WebPublic.WebPublic.Show(this, "修改失败！");
            return;
        }
    }

    #endregion


    #region   --------------上传文件------------------------

    protected void Button14_Click(object sender, EventArgs e)//上传图片
    {
        if (FileUpload1.PostedFile != null)
        {
            string filename;//文件名字
            string hz;
            string newname;
            filename = FileUpload1.FileName;
            //取后最
            int pos = filename.IndexOf(".");
            hz = filename.Substring((pos + 1)).ToLower();

            if (hz != "gif" && hz != "jpg" && hz != "jpeg" && hz != "bmp")
            {
                WebPublic.WebPublic.Show(this,"图片只支持－－－gif|jpg|jpeg|bmp");
                return;
            }
            newname = sjname() + "." + hz;
            //保存图片
            string str2 = "Ad";
            string Url = string.Format("{0}{1}/Big/{2}", FSO.GetUploadPath(), str2, FSO.RandomFileName(newname));
            string pathurl;
            pathurl = Server.MapPath(Url);
            string kb = FileUpload1.FileContent.Length.ToString();

            FileUpload1.PostedFile.SaveAs(pathurl);
            this.T1.Value = Url;
        }
    }

    protected void Button15_Click(object sender, EventArgs e)//上传图片,FLASE
    {
        if (FileUpload2.PostedFile != null)
        {
            string filename;//文件名字
            string hz;
            string newname;
            string imgtype = "gif|jpg|jpeg|bmp|swf";
            filename = FileUpload2.FileName;
            //取后最
            int pos = filename.IndexOf(".");
            hz = filename.Substring((pos + 1)).ToLower();

            if (hz != "gif" && hz != "jpg" && hz != "jpeg" && hz != "bmp")
            {
                WebPublic.WebPublic.Show(this, imgtype);
                return;
            }
            newname = sjname() + "." + hz;
            string str2 = "Ad";
            string Url = string.Format("{0}{1}/Small/{2}", FSO.GetUploadPath(), str2, FSO.RandomFileName(newname));
            //保存图片
            string pathurl;
            pathurl = Server.MapPath(Url);
            FileUpload2.PostedFile.SaveAs(pathurl);
            imgUrl.Value = Url;
        }
    }

    protected void Button16_Click(object sender, EventArgs e)//上传幻灯片
    {
        if (FileUpload3.PostedFile != null)
        {
            string filename;//文件名字
            string hz;
            string newname;
            filename = FileUpload3.FileName;
            //取后最
            int pos = filename.IndexOf(".");
            hz = filename.Substring((pos + 1)).ToLower();

            if (hz != "jpg")
            {
                WebPublic.WebPublic.Show(this, "jpg格式");
                return;
            }
            newname = sjname() + "." + hz;
            //保存图片
            string str2 = "Ad";
            string Url = string.Format("{0}{1}/Big/{2}", FSO.GetUploadPath(), str2, FSO.RandomFileName(newname));
            string pathurl;
            pathurl = Server.MapPath(Url);
            //string kb = FileUpload1.FileContent.Length.ToString();

            FileUpload3.PostedFile.SaveAs(pathurl);
            if (this.ckbox1.Checked)
            {
                imgUrlx.Text = lbimgUrlx.Text + Url + "|";
            }
            else
            {
                imgUrlx.Text = Url + "|";
            }
            lbimgUrlx.Text = imgUrlx.Text;
        }
    }

    protected void Button17_Click(object sender, EventArgs e)//修改幻灯片
    {
        if (FileUpload4.PostedFile != null)
        {
            string filename;//文件名字
            string hz;
            string newname;
            filename = FileUpload4.FileName;
            //取后最
            int pos = filename.IndexOf(".");
            hz = filename.Substring((pos + 1)).ToLower();

            if (hz != "jpg")
            {
                WebPublic.WebPublic.Show(this, "jpg格式");
                return;
            }
            newname = sjname() + "." + hz;
            //保存图片
            string str2 = "Ad";
            string Url = string.Format("{0}{1}/Big/{2}", FSO.GetUploadPath(), str2, FSO.RandomFileName(newname));
            string pathurl;
            pathurl = Server.MapPath(Url);
            //string kb = FileUpload1.FileContent.Length.ToString();
            FileUpload4.PostedFile.SaveAs(pathurl);
            if (ckbox2.Checked)
            {
                imgUrlx2.Text = lbimgUrl2.Text + Url + "|";  
            }
            else
            {
                imgUrlx2.Text = Url + "|";
            }
            lbimgUrl2.Text = imgUrlx2.Text;
        }
    }

    protected void Button18_Click(object sender, EventArgs e)//添加对联图片
    {
        if (FileUpload5.PostedFile != null)
        {

            string filename;//文件名字
            string hz;
            string newname;
            filename = FileUpload5.FileName;
            //取后最
            int pos = filename.IndexOf(".");
            hz = filename.Substring((pos + 1)).ToLower();

            if (hz != "jpg")
            {
                WebPublic.WebPublic.Show(this, "jpg格式");
                return;
            }
            newname = sjname() + "." + hz;
            //保存图片
            string str2 = "Ad";
            string Url = string.Format("{0}{1}/Big/{2}", FSO.GetUploadPath(), str2, FSO.RandomFileName(newname));
            string pathurl;
            pathurl = Server.MapPath(Url);

            FileUpload5.PostedFile.SaveAs(pathurl);
            if (ckbox3.Checked)
            {
                TextBox26.Text = lbTextBox26.Text + Url + "|";
            }
            else
            {
                TextBox26.Text = Url + "|";
            }
            lbTextBox26.Text = TextBox26.Text;
        }
    }

    protected void Button19_Click(object sender, EventArgs e)//修改对联图片
    {
        if (FileUpload6.PostedFile != null)
        {
            string filename;//文件名字
            string hz;
            string newname;
            filename = FileUpload6.FileName;
            //取后最
            int pos = filename.IndexOf(".");
            hz = filename.Substring((pos + 1)).ToLower();

            if (hz != "jpg")
            {
                WebPublic.WebPublic.Show(this, "jpg格式");
                return;
            }
            newname = sjname() + "." + hz;
            //保存图片
            string str2 = "Ad";
            string Url = string.Format("{0}{1}/Big/{2}", FSO.GetUploadPath(), str2, FSO.RandomFileName(newname));
            string pathurl;
            pathurl = Server.MapPath(Url);
            //string kb = FileUpload1.FileContent.Length.ToString();

            FileUpload6.PostedFile.SaveAs(pathurl);
            if (ckbox3.Checked)
            {
                TextBox33.Text = lbTextBox33.Text + Url + "|";
            }
            else
            {
                TextBox33.Text = Url + "|";
            }
            lbTextBox33.Text = TextBox33.Text;
        }
    }

    #endregion
    /// <summary>
    /// 产生个随即名称
    /// </summary>
    /// <returns></returns>
    public string sjname()
    {
        string sj = null;
        sj = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.TimeOfDay.Hours.ToString() + DateTime.Now.TimeOfDay.Minutes.ToString() + DateTime.Now.TimeOfDay.Milliseconds.ToString();
        return sj;
    }
}
